Developer Documentation
PATH  WebObjects 4.5 Documentation > Dynamic Elements

up

WOComponentContent



Element Description

WOComponentContent allows you to write nested components as HTML container elements: elements that can include text and other elements between their opening and closing tags. Using WOComponentContent you can, for example, write a component that defines the header and footer for all of your application's pages.

The WOComponentContent dynamic element doesn't have any attributes. It's simply a marker that specifies where the contents wrapped by the component's <WEBOBJECT> tag should go.




Synopsis

WOComponentContent { };

Example

To write a component that defines the header and footer for some or all of your application's pages, first define a component with HTML similar to the following:

<HTML>    <HEAD>        <TITLE>Cool WebObjects App</TITLE>    </HEAD>    <BODY>    <!-- A banner common to all pages here -->    <!-- Start of content defined by the parent element -->    <WEBOBJECT name=ParentContent></WEBOBJECT>    <!-- End of content defined by the parent element -->    <!-- Put a footer common to all pages here. -->    </BODY></HTML>

The <WEBOBJECT> element above is a WOComponentContent element declared like this:

ParentContent : WOComponentContent {};

To use this component, wrap the contents of all of your other components with a <WEBOBJECT> tag that specifies the component defined above. For example, suppose you named the above component HeaderFooterPage.wo. You could use it in another component like this:

<!-- HTML for a simple component wrapped with HeaderFooterPage --><WEBOBJECT name = templateWrapperElement>    <P>Hello, world!</P></WEBOBJECT>

Where templateWrapperElement is declared in the .wod file like this:

templateWrapperElement : HeaderFooterPage {};

At runtime, the contents wrapped by templateWrapperElement are substituted for the WOComponentContent definition. As a result, the HTML generated for this component would be:

<HTML>    <HEAD>        <TITLE>Cool WebObjects App</TITLE>    </HEAD>    <BODY>    <!-- A banner common to all pages here -->    <!-- Start of content defined by the parent element -->    <P>Hello, world!</P>    <!-- End of content defined by the parent element -->    <!-- Put a footer common to all pages here. -->    </BODY></HTML>


up
You can only have one WOComponentContent element in a given component.